﻿#region File and License Information
/*
<File>
	<License Type="BSD">
		Copyright © 2009 - 2012, Outcoder. All rights reserved.
	
		This file is part of Calcium (http://calciumsdk.net).

		Redistribution and use in source and binary forms, with or without
		modification, are permitted provided that the following conditions are met:
			* Redistributions of source code must retain the above copyright
			  notice, this list of conditions and the following disclaimer.
			* Redistributions in binary form must reproduce the above copyright
			  notice, this list of conditions and the following disclaimer in the
			  documentation and/or other materials provided with the distribution.
			* Neither the name of the <organization> nor the
			  names of its contributors may be used to endorse or promote products
			  derived from this software without specific prior written permission.

		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
		ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
		WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
		DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
		DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
		(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
		ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
		(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
		SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	</License>
	<Owner Name="Daniel Vaughan" Email="danielvaughan@outcoder.com" />
	<CreationDate>2010-03-25 20:43:46Z</CreationDate>
</File>
*/
#endregion

using System;
using System.Collections.Generic;
using Outcoder.ComponentModel;

namespace Outcoder.Services
{
	/// <summary>
	/// This interface specifies the minimum capabilities of a string parser,
	/// which is able to take a string and resolve any embedded string tags.
	/// </summary>
	public interface IStringParserService
	{
		/// <summary>
		/// Parses the specified text. Resolves string tags within the text.
		/// </summary>
		/// <param name="text">The text.</param>
		/// <param name="tagValues">The custom tag values. 
		/// If a tag is found in the specified text which matches one in the this parameter, 
		/// then the value in the dictionary will be substituted in the string.</param>
		/// <returns>The parsed string.</returns>
		string Parse(string text, IDictionary<string, string> tagValues);

		/// <summary>
		/// Parses the specified text. Resolves string tags within the text.
		/// </summary>
		/// <param name="text">The text.</param>
		/// <returns></returns>
		string Parse(string text);

		/// <summary>
		/// Registers a converter with the specified tag name. 
		/// When subsequently calling Parse, if a tag is discovered in the text, 
		/// then the specified IConverter will be used to convert the tag 
		/// and substitute the tag in the text.
		/// </summary>
		/// <param name="tagName">The tag identifier. E.g., "Country". 
		/// When calling Parse, if the text contains a string "Greeting from ${Country}." 
		/// The specified converter will be used to create a string replacement 
		/// for the ${Country} tag.</param>
		/// <param name="converter">The converter.</param>
		/// <example></example>
		void RegisterConverter(string tagName, IConverter converter);

//		/// <summary>
//		/// Registers a converter with the specified tag name. 
//		/// When subsequently calling Parse, if a tag is discovered in the text, 
//		/// then the specified IConverter will be used to convert the tag 
//		/// and substitute the tag in the text.
//		/// </summary>
//		/// <param name="tagName">The tag identifier. E.g., "Country". 
//		/// When calling Parse, if the text contains a string "Greeting from ${Country}." 
//		/// The specified converter will be used to create a string replacement 
//		/// for the ${Country} tag.</param>
//		void RegisterConverter(string tagName, Func<object, object> convertFunc);
	}
}